package
{
	import flash.events.EventDispatcher;
	
	import mx.events.FlexEvent;

	public class PresenceState extends EventDispatcher
	{
		public var id: String;

		[Bindable]
		public var name: String;

		private var ms_state: String;
		
		public function PresenceState(s_id: String, s_name: String, s_state: String)
		{
			this.id = s_id;
			this.name = s_name;
			this.ms_state = s_state;
		}
		
		[Bindable]
		public function set state(s_state: String): void
		{
			if(ms_state != s_state) {
				ms_state = s_state;
				dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
			}
		}

		public function get state(): String
		{
			return ms_state;
		}
		
		public static function labelForState(s: String): String
		{
			switch(s) {
				case "in.meeting": return "At work, in a meeting";
				case "in.course": return "At work, in course";
				case "in.idle": return "At work, idle/leisure";
				case "in.work": return "At work";
				case "out.business-trip": return "Away for business trip";
				case "out.work": return "Away for business/work";
				case "out.doctor": return "Away for doctor visit";
				case "out.holidays": return "Away on holidays";
				case "out.home": return "Away, went home";
				case "out.will-return": return "Away, but will return";
				case "out.ill": return "Away due to illness";
				case "out.lunch": return "Away for lunch/food";
				case "out.training": return "Away for training";
			}
			return s;
		}
	}
}